#! /bin/bash
echo
echo "/************** 开始安装插件 ****************/"

# 在此处列出需要安装的插件
PLUGINS="hexo-generator-searchdb hexo-filter-flowchart hexo-deployer-git hexo-sliding-spoiler hexo-symbols-count-time github-webhook-handler"
npm list --depth 0 > /tmp/hexo_npm_list.txt
# 安装未安装的插件
for plugin in $PLUGINS; do
    search=$(cat /tmp/hexo_npm_list.txt | grep ${plugin})
    length=${#search}
    if [ $length -gt 0 ]; then
        echo "Plugin $plugin was installed"
    else
        npm install --save $plugin
    fi
done

echo "/************** 插件安装完毕 ****************/"
echo

# npm install hexo-generator-searchdb
# npm install --save hexo-filter-flowchart
# npm install --save hexo-deployer-git
# # npm install -save theme-next/theme-next-calendar
# npm install --save hexo-sliding-spoiler
# npm install hexo-symbols-count-time
# # npm install -save hexo-leancloud-counter-security
#  index=$(expr index "$installed_plugins" "$plugin")
#     echo $installed_plugins
#     echo $plugin
#     echo $index
#     echo ""
